import {fromJS, Map} from "immutable";
import {save_car_data} from "./actionCreator";

/**
 *
 * carMapData: 数据说明 Map(key:pageNumber,data:[])
 */

const map = Map();
const defaultStatus = fromJS({
    pageNumber: 1,
    carMapData: map

});


export default (status = defaultStatus, action) => {

    switch (action.type) {
        case save_car_data:
            const pageNumber = action.pageNumber;

            const dataMap = status.get("carMapData");
            const newDataMap = dataMap.set(pageNumber, fromJS(action.data));

            return status.merge({
                pageNumber: pageNumber,
                carMapData: newDataMap
            });
        default:
            return status;
    }
}